package com.ltkj.baseplatform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.baseplatform.domain.vo.SerTravelNotesVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.baseplatform.domain.SerTravelNotes;
import com.ltkj.baseplatform.service.ISerTravelNotesService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 游记管理Controller
 * 
 * @author ruoyi
 * @date 2023-09-03
 */
@Api(tags = "游记管理")
@RestController
@RequestMapping("/notes")
public class SerTravelNotesController extends BaseController
{
    @Autowired
    private ISerTravelNotesService serTravelNotesService;

    /**
     * 查询游记管理列表
     */
    @ApiOperation("查询游记管理列表")
    @RequiresPermissions("baseplatform:notes:list")
    @GetMapping("/list")
    public TableDataInfo list(SerTravelNotes serTravelNotes)
    {
        startPage();
        List<SerTravelNotesVo> list = serTravelNotesService.selectSerTravelNotesList(serTravelNotes);
        return getDataTable(list);
    }

    /**
     * 导出游记管理列表
     */
    /*@ApiOperation("导出游记管理列表")
    @RequiresPermissions("baseplatform:notes:export")
    @Log(title = "游记管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerTravelNotes serTravelNotes)
    {
        List<SerTravelNotes> list = serTravelNotesService.selectSerTravelNotesList(serTravelNotes);
        ExcelUtil<SerTravelNotes> util = new ExcelUtil<SerTravelNotes>(SerTravelNotes.class);
        util.exportExcel(response, list, "游记管理数据");
    }*/

    /**
     * 获取游记管理详细信息
     */
    @ApiOperation("获取游记管理详细信息")
    @RequiresPermissions("baseplatform:notes:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serTravelNotesService.selectSerTravelNotesById(id));
    }

    /**
     * 新增游记管理
     */
    @ApiOperation("新增游记管理")
    @RequiresPermissions("baseplatform:notes:add")
    @Log(title = "游记管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SerTravelNotes serTravelNotes)
    {
        return toAjax(serTravelNotesService.insertSerTravelNotes(serTravelNotes));
    }

    /**
     * 修改游记管理
     */
    @ApiOperation("修改游记管理")
    @RequiresPermissions("baseplatform:notes:edit")
    @Log(title = "游记管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SerTravelNotes serTravelNotes)
    {
        return toAjax(serTravelNotesService.updateSerTravelNotes(serTravelNotes));
    }

    /**
     * 删除游记管理
     */
    @ApiOperation("删除游记管理")
    @RequiresPermissions("baseplatform:notes:remove")
    @Log(title = "游记管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serTravelNotesService.deleteSerTravelNotesByIds(ids));
    }
}
